package com.lanhe.app.controller.adSetEarnings;

import com.lanhe.common.annotation.Log;
import com.lanhe.common.core.controller.BaseController;
import com.lanhe.common.core.domain.AjaxResult;
import com.lanhe.common.core.page.TableDataInfo;
import com.lanhe.common.enums.BusinessType;
import com.lanhe.common.utils.poi.ExcelUtil;
import com.lanhe.game.adSetEarnings.domain.LhAdsetEarnings;
import com.lanhe.game.adSetEarnings.service.ILhAdsetEarningsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 看广软件的收益分发Controller
 * 
 * @author tianliang
 * @date 2024-02-06
 */
@RestController
@RequestMapping("/earnings/earnings")
public class LhAdsetEarningsController extends BaseController
{
    @Autowired
    private ILhAdsetEarningsService lhAdsetEarningsService;

    /**
     * 查询看广软件的收益分发列表
     */
    @PreAuthorize("@ss.hasPermi('earnings:earnings:list')")
    @GetMapping("/list")
    public TableDataInfo list(LhAdsetEarnings lhAdsetEarnings)
    {
        startPage();
        List<LhAdsetEarnings> list = lhAdsetEarningsService.selectLhAdsetEarningsList(lhAdsetEarnings);
        return getDataTable(list);
    }

    /**
     * 导出看广软件的收益分发列表
     */
    @PreAuthorize("@ss.hasPermi('earnings:earnings:export')")
    @Log(title = "看广软件的收益分发", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LhAdsetEarnings lhAdsetEarnings)
    {
        List<LhAdsetEarnings> list = lhAdsetEarningsService.selectLhAdsetEarningsList(lhAdsetEarnings);
        ExcelUtil<LhAdsetEarnings> util = new ExcelUtil<LhAdsetEarnings>(LhAdsetEarnings.class);
        util.exportExcel(response, list, "看广软件的收益分发数据");
    }

    /**
     * 获取看广软件的收益分发详细信息
     */
    @PreAuthorize("@ss.hasPermi('earnings:earnings:query')")
    @GetMapping(value = "/{adId}")
    public AjaxResult getInfo(@PathVariable("adId") Long adId)
    {
        return success(lhAdsetEarningsService.selectLhAdsetEarningsByAdId(adId));
    }

    /**
     * 新增看广软件的收益分发
     */
    @PreAuthorize("@ss.hasPermi('earnings:earnings:add')")
    @Log(title = "看广软件的收益分发", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LhAdsetEarnings lhAdsetEarnings)
    {
        return toAjax(lhAdsetEarningsService.insertLhAdsetEarnings(lhAdsetEarnings));
    }

    /**
     * 修改看广软件的收益分发
     */
    @PreAuthorize("@ss.hasPermi('earnings:earnings:edit')")
    @Log(title = "看广软件的收益分发", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LhAdsetEarnings lhAdsetEarnings)
    {
        return toAjax(lhAdsetEarningsService.updateLhAdsetEarnings(lhAdsetEarnings));
    }

    /**
     * 删除看广软件的收益分发
     */
    @PreAuthorize("@ss.hasPermi('earnings:earnings:remove')")
    @Log(title = "看广软件的收益分发", businessType = BusinessType.DELETE)
	@DeleteMapping("/{adIds}")
    public AjaxResult remove(@PathVariable Long[] adIds)
    {
        return toAjax(lhAdsetEarningsService.deleteLhAdsetEarningsByAdIds(adIds));
    }
}
